#include<bits/stdc++.h>
using namespace std;
#define int long long

int x[1000005], y[1000005];

signed main() {
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		cin >> x[i] >> y[i];
	}
	sort(x + 1, x + k + 1);
	sort(y + 1, y + k + 1);

	int cnt1 = 0, cnt2 = 0;
	for (int i = 1; i <= k; i++) {
		if (x[i] != x[i - 1])	cnt1++;
		if (y[i] != y[i - 1])	cnt2++;
	}
	cout << n*n - (n - cnt1)*(n - cnt2);
	return 0;
}
